//
//  ZDMyTextField.m
//  SSSMerchant
//
//  Created by Darker on 2017/3/24.
//  Copyright © 2017年 xnxin. All rights reserved.
//

#import "ZDMyTextField.h"

@implementation ZDMyTextField

/**- (CGRect)borderRectForBounds:(CGRect)bounds;
 - (CGRect)textRectForBounds:(CGRect)bounds;
 - (CGRect)placeholderRectForBounds:(CGRect)bounds;
 - (CGRect)editingRectForBounds:(CGRect)bounds;
 - (CGRect)clearButtonRectForBounds:(CGRect)bounds;
 - (CGRect)leftViewRectForBounds:(CGRect)bounds;
 - (CGRect)rightViewRectForBounds:(CGRect)bounds;
 
 - (void)drawTextInRect:(CGRect)rect;
 - (void)drawPlaceholderInRect:(CGRect)rect;
 opacity:0.55;
 font-family:PingFangSC-Regular;
 font-size:14px;
 color:#FFFFFF;
 line-height:20px;
 text-align:left;
 */
- (void)drawRect:(CGRect)rect {
    // 4, 描述占位文字属性
    NSMutableDictionary *attr = [NSMutableDictionary dictionary];
    attr[NSForegroundColorAttributeName] = [UIColor colorWithHex:@"A2A2A2" alpha:1];
    // 5, 富文本属性
    NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:self.placeholder attributes:attr];
    self.attributedPlaceholder = attribute;
    
}

- (CGRect)placeholderRectForBounds:(CGRect)bounds
{
    //return CGRectInset(bounds, 20, 0);
    //    CGRect inset = CGRectMake(bounds.origin.x+100, bounds.origin.y, bounds.size.width -10, bounds.size.height);
    //    return inset;
    return CGRectOffset(bounds, WidthIos6CompeteWithCurrent(30), 0);
}

- (CGRect)editingRectForBounds:(CGRect)bounds {
    return CGRectOffset(bounds, WidthIos6CompeteWithCurrent(30), 0);
}

- (CGRect)leftViewRectForBounds:(CGRect)bounds {
    CGRect inset = CGRectMake(bounds.origin.x + WidthIos6CompeteWithCurrent(9), (self.bounds.size.height - HeigthIos6CompeteWithCurrent(16)) / 2, WidthIos6CompeteWithCurrent(12), HeigthIos6CompeteWithCurrent(15));
    
    CGRect newInsert = CGRectMake(bounds.origin.x + WidthIos6CompeteWithCurrent(12), (self.bounds.size.height - HeigthIos6CompeteWithCurrent(16)) / 2, WidthIos6CompeteWithCurrent(16), HeigthIos6CompeteWithCurrent(16));
    return self.widthView?newInsert:inset;
}

- (CGRect)textRectForBounds:(CGRect)bounds {
    return CGRectOffset(bounds, WidthIos6CompeteWithCurrent(30), 0);
}

- (CGRect)rightViewRectForBounds:(CGRect)bounds {
    CGRect inset = CGRectMake(bounds.size.width - WidthIos6CompeteWithCurrent(31), (bounds.size.height - HeigthIos6CompeteWithCurrent(8)) / 2, WidthIos6CompeteWithCurrent(18), HeigthIos6CompeteWithCurrent(8));
    return inset;
}


@end
